//共阴数码管: COM = 低电平, SEG = 高电平, 数码管亮
//COM0 百位
//COM1 十位
//COM2 个位
//COM3 冒号位

#include "apt32f102_gpio.h"


#ifndef HAL_NIXIETUBE_H
#define HAL_NIXIETUBE_H

//GPIO驱动类型
#define GPIO_Type GPIO_EXI_TypeDef
//GPIO口
//nixie-tube
#define IO_Tube_Seg0 EXI3 //PA
#define IO_Tube_Seg1 EXI1 //PA
#define IO_Tube_Seg2 EXI0 //PA
#define IO_Tube_Seg3 EXI15 //PA
#define IO_Tube_Seg4 EXI5 //PB
#define IO_Tube_Seg5 EXI4 //PB
#define IO_Tube_Seg6 EXI1 //PB
#define IO_Tube_Seg7 EXI14 //PA
#define IO_Tube_Com0 EXI0 //PB 
#define IO_Tube_Com1 EXI13 //PA 
#define IO_Tube_Com2 EXI12 //PA 
#define IO_Tube_Com3 EXI4 //PA 

#define Seg0_H GPIO_Write_High(GPIOA0,IO_Tube_Seg0)
#define Seg0_L GPIO_Write_Low(GPIOA0,IO_Tube_Seg0)
#define Seg1_H GPIO_Write_High(GPIOA0,IO_Tube_Seg1)
#define Seg1_L GPIO_Write_Low(GPIOA0,IO_Tube_Seg1)
#define Seg2_H GPIO_Write_High(GPIOA0,IO_Tube_Seg2)
#define Seg2_L GPIO_Write_Low(GPIOA0,IO_Tube_Seg2)
#define Seg3_H GPIO_Write_High(GPIOA0,IO_Tube_Seg3)
#define Seg3_L GPIO_Write_Low(GPIOA0,IO_Tube_Seg3)
#define Seg4_H GPIO_Write_High(GPIOB0,IO_Tube_Seg4)
#define Seg4_L GPIO_Write_Low(GPIOB0,IO_Tube_Seg4)
#define Seg5_H GPIO_Write_High(GPIOB0,IO_Tube_Seg5)
#define Seg5_L GPIO_Write_Low(GPIOB0,IO_Tube_Seg5)
#define Seg6_H GPIO_Write_High(GPIOB0,IO_Tube_Seg6)
#define Seg6_L GPIO_Write_Low(GPIOB0,IO_Tube_Seg6)
#define Seg7_H GPIO_Write_High(GPIOA0,IO_Tube_Seg7)
#define Seg7_L GPIO_Write_Low(GPIOA0,IO_Tube_Seg7)
#define Com0_H GPIO_Write_High(GPIOB0,IO_Tube_Com0)
#define Com0_L GPIO_Write_Low(GPIOB0,IO_Tube_Com0)
#define Com1_H GPIO_Write_High(GPIOA0,IO_Tube_Com1)
#define Com1_L GPIO_Write_Low(GPIOA0,IO_Tube_Com1)
#define Com2_H GPIO_Write_High(GPIOA0,IO_Tube_Com2)
#define Com2_L GPIO_Write_Low(GPIOA0,IO_Tube_Com2)
#define Com3_H GPIO_Write_High(GPIOA0,IO_Tube_Com3)
#define Com3_L GPIO_Write_Low(GPIOA0,IO_Tube_Com3)

typedef enum
{
    Tube_Encoder_Dot = 10, //.
    Tube_Encoder_E = 11, //E
    Tube_Encoder_r = 12, //r
    Tube_Encoder_None = 13, //不显示
    Tube_Encoder_n = 14, //n
    Tube_Encoder_o = 15, //小写 o
    Tube_Encoder_P = 23, //大写 P
    Tube_Encoder_p = 16, //小写 p
    Tube_Encoder_L = 17, //L
    Tube_Encoder_Dash = 19, //-
    Tube_Encoder_H = 18, //H
    Tube_Encoder_F = 20, //F
    Tube_Encoder_S = 21, //S
    Tube_Encoder_O = 22, //大写O
    Tube_Encoder_C = 24, //C
    Tube_Encoder_v = 25, //v
    Tube_Encoder_Colon = 26, //:
}Tube_Encoder;


void NT_Init(void);
void NT_Main(void);
void NT_NumsSettings(int32_t num);
void NT_CharsSettings(uint32_t num);
void Tube_Clock(void);
void NT_Shine_Rest(void);
void NT_Shine_Stop(void);

#endif
